const Generator = require('yeoman-generator')

module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type: 'input',
                name: 'name',
                message: '输入你的项目名称',
                default: this.appname
            }
        ]).then(answers => {
            this.answers = answers
        })
    }

    writing() {
        const template = [
            'tsconfig.json',
            'README.md',
            'postcss.config.js',
            'package.json',
            'build/build.js',
            'build/webpack.base.conf.js',
            'build/webpack.dev.conf.js',
            'build/webpack.prod.conf.js',
            'public/index.html',
            'src/assets/css/index.css',
            'src/assets/images/logo.png',
            'src/assets/images/page1.jpg',
            'src/assets/images/page2.jpg',
            'src/components/img-temp.vue',
            'src/components/logo.png',
            'src/router/index.ts',
            'src/App.vue',
            'src/view/Home.vue',
            'src/view/page1.vue',
            'src/view/page2.vue'
        ]
        template.forEach(element => {
            this.fs.copyTpl(
                this.templatePath(element),
                this.destinationPath(element),
                this.answers
            )
        })
    }
}
